package com.freesky.provider.search.controller;

import com.freesky.common.enums.ResponseEnum;
import com.freesky.common.exception.MyException;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.provider.search.service.ISearchItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 17:08 2018/11/29
 * @description:
 */
@RestController
@RequestMapping("/search")
public class SearchItemController {
    @Autowired
    private ISearchItemService searchItemService;

    @RequestMapping(value = "/importIndex",method = RequestMethod.GET)
    public JSONResponse importIndex(){
        try {
            return searchItemService.importAllItems();
        } catch (Exception e) {
            throw new MyException(ResponseEnum.UPDATE_SOLR_INDEX_FAIL,e, null);
        }
    }

    @RequestMapping(value = "/getInfo",method = RequestMethod.GET)
    public JSONResponse getInfo(){
        return searchItemService.getInfo();
    }
}
